package com.huwaiwai.jvm.d20191226;

/**
 * @author 歪大哥😁
 * @date 2019-12-26.
 */
public class Singleton {

    public static String test() {
        return "super";
    }
//    private Singleton() {}

    private static class LazyHolder {
        static final Singleton INSTANCE = new Singleton();
        static {
            System.out.println("lazyHolder.clinit");
        }
    }

    public static Object getInstance(boolean flag) {
        if (flag) {
            return new LazyHolder[2];
        }
        return LazyHolder.INSTANCE;
    }

    public static void main(String[] args) {
        getInstance(true);
        System.out.println("------");
        getInstance(false);
    }

}


